import pandas as pd

def extract_spi(file_path):
    """
    提取SPI数据的核心逻辑
    """
    data = pd.read_csv(file_path)
    current_group_sdo = []
    groups = []
    for index, row in data.iterrows():
        status = row.iloc[0].strip('="')
        cleaned_row = [item.strip('=" ') for item in row.iloc[1:17]]
        cleaned_row = [f"0x{item}" for item in cleaned_row if item]
        if status == 'Idle':
            if current_group_sdo:
                groups.append(current_group_sdo)
                current_group_sdo = []
        elif status == 'SDO':
            current_group_sdo.extend(cleaned_row)
    if current_group_sdo:
        groups.append(current_group_sdo)
    return groups